package com.example.lesson_10_25.JAVAHW.H1127;

/**
 * @PACKAGE_NAME: com.example.lesson_10_25.JAVAHW.H1127
 * @NAME: A
 * @USER: jiang000
 * @DATE: 2023/12/4
 **/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Student {
    private String name;
    private double mathScore;
    private double programmingScore;
    private double englishScore;

    public Student(String name, double mathScore, double programmingScore, double englishScore) {
        this.name = name;
        this.mathScore = mathScore;
        this.programmingScore = programmingScore;
        this.englishScore = englishScore;
    }

    public String getName() {
        return name;
    }

    public double getMathScore() {
        return mathScore;
    }

    public double getProgrammingScore() {
        return programmingScore;
    }

    public double getEnglishScore() {
        return englishScore;
    }

    public double getTotalScore() {
        return mathScore + programmingScore + englishScore;
    }

    public double getAverageScore() {
        return getTotalScore() / 3;
    }
}

public class A {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();

        students.add(new Student("John Doe", 90, 85, 92));
        students.add(new Student("Jane Smith", 78, 88, 95));
        students.add(new Student("Bob Johnson", 85, 92, 89));

        // Sort students based on total score in descending order
        Collections.sort(students, (s1, s2) -> Double.compare(s2.getTotalScore(), s1.getTotalScore()));

        // Output student information
        System.out.println("Student Information Sorted by Total Score:");
        System.out.printf("%-15s %-10s %-15s %-15s %-15s %-15s%n",
                "Name", "Math", "Programming", "English", "Total Score", "Average Score");

        for (Student student : students) {
            System.out.printf("%-15s %-10.2f %-15.2f %-15.2f %-15.2f %-15.2f%n",
                    student.getName(),
                    student.getMathScore(),
                    student.getProgrammingScore(),
                    student.getEnglishScore(),
                    student.getTotalScore(),
                    student.getAverageScore());
        }
    }
}